<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN"
   "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
<html>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8"/>
<head>
    <title>CPML documentation</title>
    <link rel="stylesheet" href="../ldoc.css" type="text/css" />
</head>
<body>

<div id="container">

<div id="product">
	<div id="product_logo"></div>
	<div id="product_name"><big><b></b></big></div>
	<div id="product_description"></div>
</div> <!-- id="product" -->


<div id="main">


<!-- Menu -->

<div id="navigation">
<br/>
<h1>CPML</h1>

<ul>
  <li><a href="../index.html">Index</a></li>
</ul>

<h2>Contents</h2>
<ul>
<li><a href="#Functions">Functions</a></li>
</ul>


<h2>Modules</h2>
<ul class="$(kind=='Topics' and '' or 'nowrap'">
  <li><a href="../modules/color.html">color</a></li>
  <li><a href="../modules/constants.html">constants</a></li>
  <li><a href="../modules/intersect.html">intersect</a></li>
  <li><a href="../modules/mat4.html">mat4</a></li>
  <li><a href="../modules/mesh.html">mesh</a></li>
  <li><a href="../modules/octree.html">octree</a></li>
  <li><a href="../modules/quat.html">quat</a></li>
  <li><a href="../modules/simplex.html">simplex</a></li>
  <li><strong>utils</strong></li>
  <li><a href="../modules/vec2.html">vec2</a></li>
  <li><a href="../modules/vec3.html">vec3</a></li>
</ul>

</div>

<div id="content">

<h1>Module <code>utils</code></h1>
<p>Various utility functions</p>
<p>

</p>


<h2><a href="#Functions">Functions</a></h2>
<table class="function_list">
	<tr>
	<td class="name" nowrap><a href="#clamp">clamp (value, min, max)</a></td>
	<td class="summary">Clamps a value within the specified range.</td>
	</tr>
	<tr>
	<td class="name" nowrap><a href="#deadzone">deadzone (value, size)</a></td>
	<td class="summary">Returns <code>value</code> if it is equal or greater than |<code>size</code>|, or 0.</td>
	</tr>
	<tr>
	<td class="name" nowrap><a href="#threshold">threshold (value, threshold)</a></td>
	<td class="summary">Check if value is equal or greater than threshold.</td>
	</tr>
	<tr>
	<td class="name" nowrap><a href="#tolerance">tolerance (value, threshold)</a></td>
	<td class="summary">Check if value is equal or less than threshold.</td>
	</tr>
	<tr>
	<td class="name" nowrap><a href="#map">map (value, min_in, max_in, min_out, max_out)</a></td>
	<td class="summary">Scales a value from one range to another.</td>
	</tr>
	<tr>
	<td class="name" nowrap><a href="#lerp">lerp (progress, low, high)</a></td>
	<td class="summary">Linear interpolation.</td>
	</tr>
	<tr>
	<td class="name" nowrap><a href="#smoothstep">smoothstep (progress, low, high)</a></td>
	<td class="summary">Hermite interpolation.</td>
	</tr>
	<tr>
	<td class="name" nowrap><a href="#round">round (value, precision)</a></td>
	<td class="summary">Round number at a given precision.</td>
	</tr>
	<tr>
	<td class="name" nowrap><a href="#wrap">wrap (value, limit)</a></td>
	<td class="summary">Wrap <code>value</code> around if it exceeds <code>limit</code>.</td>
	</tr>
	<tr>
	<td class="name" nowrap><a href="#is_pot">is_pot (value)</a></td>
	<td class="summary">Check if a value is a power-of-two.</td>
	</tr>
</table>

<br/>
<br/>


    <h2 class="section-header "><a name="Functions"></a>Functions</h2>

    <dl class="function">
    <dt>
    <a name = "clamp"></a>
    <strong>clamp (value, min, max)</strong>
    </dt>
    <dd>
    Clamps a value within the specified range.


    <h3>Parameters:</h3>
    <ul>
        <li><span class="parameter">value</span>
         Input value
        </li>
        <li><span class="parameter">min</span>
         Minimum output value
        </li>
        <li><span class="parameter">max</span>
         Maximum output value
        </li>
    </ul>

    <h3>Returns:</h3>
    <ol>

        number
    </ol>




</dd>
    <dt>
    <a name = "deadzone"></a>
    <strong>deadzone (value, size)</strong>
    </dt>
    <dd>
    Returns <code>value</code> if it is equal or greater than |<code>size</code>|, or 0.


    <h3>Parameters:</h3>
    <ul>
        <li><span class="parameter">value</span>



        </li>
        <li><span class="parameter">size</span>



        </li>
    </ul>

    <h3>Returns:</h3>
    <ol>

        number
    </ol>




</dd>
    <dt>
    <a name = "threshold"></a>
    <strong>threshold (value, threshold)</strong>
    </dt>
    <dd>
    Check if value is equal or greater than threshold.


    <h3>Parameters:</h3>
    <ul>
        <li><span class="parameter">value</span>



        </li>
        <li><span class="parameter">threshold</span>



        </li>
    </ul>

    <h3>Returns:</h3>
    <ol>

        boolean
    </ol>




</dd>
    <dt>
    <a name = "tolerance"></a>
    <strong>tolerance (value, threshold)</strong>
    </dt>
    <dd>
    Check if value is equal or less than threshold.


    <h3>Parameters:</h3>
    <ul>
        <li><span class="parameter">value</span>



        </li>
        <li><span class="parameter">threshold</span>



        </li>
    </ul>

    <h3>Returns:</h3>
    <ol>

        boolean
    </ol>




</dd>
    <dt>
    <a name = "map"></a>
    <strong>map (value, min_in, max_in, min_out, max_out)</strong>
    </dt>
    <dd>
    Scales a value from one range to another.


    <h3>Parameters:</h3>
    <ul>
        <li><span class="parameter">value</span>
         Input value
        </li>
        <li><span class="parameter">min_in</span>
         Minimum input value
        </li>
        <li><span class="parameter">max_in</span>
         Maximum input value
        </li>
        <li><span class="parameter">min_out</span>
         Minimum output value
        </li>
        <li><span class="parameter">max_out</span>
         Maximum output value
        </li>
    </ul>

    <h3>Returns:</h3>
    <ol>

        number
    </ol>




</dd>
    <dt>
    <a name = "lerp"></a>
    <strong>lerp (progress, low, high)</strong>
    </dt>
    <dd>
    Linear interpolation.
 Performs linear interpolation between 0 and 1 when <code>low</code> &lt; <code>progress</code> &lt; <code>high</code>.


    <h3>Parameters:</h3>
    <ul>
        <li><span class="parameter">progress</span>
         (0-1)
        </li>
        <li><span class="parameter">low</span>
         value to return when <code>progress</code> is 0
        </li>
        <li><span class="parameter">high</span>
         value to return when <code>progress</code> is 1
        </li>
    </ul>

    <h3>Returns:</h3>
    <ol>

        number
    </ol>




</dd>
    <dt>
    <a name = "smoothstep"></a>
    <strong>smoothstep (progress, low, high)</strong>
    </dt>
    <dd>
    Hermite interpolation.
 Performs smooth Hermite interpolation between 0 and 1 when <code>low</code> &lt; <code>progress</code> &lt; <code>high</code>.


    <h3>Parameters:</h3>
    <ul>
        <li><span class="parameter">progress</span>
         (0-1)
        </li>
        <li><span class="parameter">low</span>
         value to return when <code>progress</code> is 0
        </li>
        <li><span class="parameter">high</span>
         value to return when <code>progress</code> is 1
        </li>
    </ul>

    <h3>Returns:</h3>
    <ol>

        number
    </ol>




</dd>
    <dt>
    <a name = "round"></a>
    <strong>round (value, precision)</strong>
    </dt>
    <dd>
    Round number at a given precision.
 Truncates <code>value</code> at <code>precision</code> points after the decimal (whole number if
 left unspecified).


    <h3>Parameters:</h3>
    <ul>
        <li><span class="parameter">value</span>



        </li>
        <li><span class="parameter">precision</span>



        </li>
    </ul>

    <h3>Returns:</h3>
    <ol>

        number
    </ol>




</dd>
    <dt>
    <a name = "wrap"></a>
    <strong>wrap (value, limit)</strong>
    </dt>
    <dd>
    Wrap <code>value</code> around if it exceeds <code>limit</code>.


    <h3>Parameters:</h3>
    <ul>
        <li><span class="parameter">value</span>



        </li>
        <li><span class="parameter">limit</span>



        </li>
    </ul>

    <h3>Returns:</h3>
    <ol>

        number
    </ol>




</dd>
    <dt>
    <a name = "is_pot"></a>
    <strong>is_pot (value)</strong>
    </dt>
    <dd>
    Check if a value is a power-of-two.
 Returns true if a number is a valid power-of-two, otherwise false.


    <h3>Parameters:</h3>
    <ul>
        <li><span class="parameter">value</span>



        </li>
    </ul>

    <h3>Returns:</h3>
    <ol>

        boolean
    </ol>




</dd>
</dl>


</div> <!-- id="content" -->
</div> <!-- id="main" -->
<div id="about">
<i>generated by <a href="http://github.com/stevedonovan/LDoc">LDoc 1.4.3</a></i>
<i style="float:right;">Last updated 2016-08-21 20:32:28 </i>
</div> <!-- id="about" -->
</div> <!-- id="container" -->
</body>
</html>
